import React from 'react'
import {NavBar} from 'antd-mobile'
import {Switch, Route} from 'react-router-dom'

import Tab from '../tab/tab' 
import Home from '../home/home'
import User from '../user/user'
import Login from '../../container/login/login'
import Register from '../../container/register/register'
import Nopage from '../../components/nopage/nopage'

class Dashboard extends React.Component {

    render() {
        const {pathname} = this.props.location
        const NoShowTab = ['/home','/user']
        const navList = [
            {
                path: '/home',
                text: '热映',
                icon: 'boss',
                title: '主页列表',
                component: Home
            },
            {
                path: '/user',
                text: '我的',
                icon: 'user',
                title: '我的列表',
                component: User
            }
        ]
        return (
            <div>
                <Switch>                     
                    {navList.map(v => (
                        <Route key={v.path} path={v.path} component={v.component} />
                    ))}
                    <Route path='/login' component={Login}/> 
                    <Route path='/register' component={Register}/>
                    <Route component={Nopage}/>                                      
                </Switch>
                {NoShowTab.indexOf(pathname) > -1 ? <Tab data={navList}></Tab> : ''}
            </div>
        )
    }
}

export default Dashboard